﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Normal;
using NormalTests.AdventureWorks;
using System.Collections.Generic;

namespace ExampleWeb
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DAO<Employee> dao = new DAO<Employee>(
                    ConfigurationManager.ConnectionStrings["adworks"].ConnectionString,
                    ConfigurationManager.ConnectionStrings["adworks"].ProviderName
                    );
                List<Employee> lst = dao.FindAll();
                grid.DataSource = lst;
                grid.DataBind();
                dao = null;
            }
        }

        protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            DAO<Employee> dao = new DAO<Employee>(
                ConfigurationManager.ConnectionStrings["adworks"].ConnectionString,
                ConfigurationManager.ConnectionStrings["adworks"].ProviderName
                );
            long NrPages = 0;
            List<Employee> lst = dao.FindByCriteria(null, e.NewPageIndex, grid.PageSize, out NrPages);
            grid.DataSource = lst;
            grid.DataBind();
            dao = null;
        }
    }
}
